#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,l,r;
	long long maxn=-1;
	scanf("%lld%lld%lld",&n,&l,&r);
	for(int i=l;i<=r;i++){
		if(maxn<i%n)
		maxn=i%n;
		if(maxn==n-1)
		break;
	}
	cout<<maxn<<endl;
	return 0;
}
